<template lang="pug">
    skin(@up="up",@down="down",@yes="yes",@back="back",@duringUp="up",@duringDown="down")
        div(class="flex-column exhaust-history")
            div(class="flex-column-item flex-center-center h3 under-line") --警示记录回顾--
            div(class="flex-column-item flex-row h3" v-for="item in currentPageMenus")
                div(class="flex-row-item") {{item.date}}
                div(class="flex-row-item center") {{item.time}}
                div(class="flex-row-item right") {{item.amount}}
            div(class="flex-column-item",:class="'flex-'+(3-currentPageMenus.length)")
</template>

<script>
    export default {
        data() {
            return {
                items: [
                    {date: "0303", time: "02:02", amount: '低药'},
                    {date: "0304", time: "04:02", amount: '低药'},
                    {date: "0305", time: "05:02", amount: '低药'},
                    {date: "0306", time: "06:02", amount: '低药'},
                    {date: "0307", time: "02:02", amount: '低药'},
                    {date: "0308", time: "02:02", amount: '低药'},
                    {date: "0309", time: "02:02", amount: '低药'},
                    {date: "0310", time: "02:02", amount: '低药'},
                    {date: "0311", time: "02:02", amount: '低药'},
                    {date: "0312", time: "02:02", amount: '低药'},
                    {date: "0313", time: "02:02", amount: '低药'}
                ].reverse(),
                page: {pageIndex: 1, pageSize: 3}
            };
        },
        computed: {
            currentPageMenus() {
                const start = (this.page.pageIndex - 1) * this.page.pageSize;
                const end = start + this.page.pageSize;
                return this.items.slice(start, end);
            },
            totalPage() {
                const zs = Math.round(this.items.length / this.page.pageSize);
                return this.items.length % this.page.pageSize == 0 ? zs : zs + 1;
            }
        },

        methods: {
            up() {
                this.page.pageIndex =
                    this.page.pageIndex == 1 ? this.totalPage - 1 : this.page.pageIndex - 1;
            },
            down() {
                this.page.pageIndex =
                    this.page.pageIndex == this.totalPage - 1 ? 1 : this.page.pageIndex + 1;
            },

            back() {
                this.$router.push("index?index=5");
            },
            yes() {
            }
        },
        created() {
        }
    };
</script>

<style lang="less">

</style>
